// 获取元素
var ulbox = document.querySelector(".ulbox");
 (function(){
    // var regExp = /(?<=imgurl=)[^'"]*/;
    var xhr = new XMLHttpRequest();

    xhr.open("get","http://chst.vip:1234/api/getsitenav");
    xhr.send(null);
    xhr.onreadystatechange = function(){
        if(xhr.readyState === 4 && xhr.status === 200){
            var res = JSON.parse(xhr.responseText);
            console.log(res);
            console.log(res.result);
            var ele = "";
            res.result.forEach(item => {
                // var img = regExp.exec(item.navImg);
                ele += `
                <li>
                <button> <img src="${item.navImg}" alt="">${item.navTitle}</button>
                </li>
                `
            });
        // 获取元素
      ulbox.innerHTML = ele;
           
        }
    }
 })();